﻿using AutoMapper;
using Pay.Data;
using Pay.DTO;
using Pay.IService;

namespace Pay.Service.AutoMapper {
    public class DistributionProductMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public DistributionProductMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        public void Create() {
            _cfg.CreateMap<distribution_product_dto, distribution_product_ex>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.categoryid, src => src.MapFrom(c => c.categoryid))
                .ForMember(dest => dest.merchantid, src => src.MapFrom(c => c.merchantid))
                .ForMember(dest => dest.productid, src => src.MapFrom(c => c.productid))
                .ForMember(dest => dest.product, src => src.MapFrom(c => c.product));
            _cfg.CreateMap<DistributionProduct, distribution_product_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.merchantid, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.productid, src => src.MapFrom(c => c.ProductId));
            _cfg.CreateMap<distribution_product_dto, DistributionProduct>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
                .ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchantid))
                .ForMember(dest => dest.ProductId, src => src.MapFrom(c => c.productid));
        }
    }
}
